package com.lankystar.sos.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lankystar.sos.dao.IHospitalDao;
import com.lankystar.sos.model.Hospital;
import com.lankystar.sos.service.IHospitalInterface;

@Service
@Transactional
public class HospitalInterface implements IHospitalInterface{

	@Autowired
	private IHospitalDao hospitalDao;
	@Override
	public Map<String, Object> queryHospitallistMethod(Double longitude,Double latitude ) {
		Map<String, Object> maplist = new HashMap<>();
		List<Hospital> hospitals = hospitalDao.selectHospitallist(longitude, latitude);
		Object[] ob = new Object[hospitals.size()];
		int i = 0;
		for (Hospital h : hospitals) {
			Map<String, Object> map = new HashMap<>();
			map.put("hospitalId", h.getHospitalId());
			map.put("hospitalName", h.getHospitalName());
			map.put("hospitalPhone", h.getHospitalPhone());
			map.put("createTime", h.getCreateTime());
			map.put("hospitalAddress", h.getHospitalAddress());
			map.put("lastUpdateTime", h.getLastUpdateTime());
			map.put("latitude", h.getLatitude());
			map.put("longitude", h.getLongitude());
			ob[i] = map;
			i++;
		}
		maplist.put("Hospital", ob);
		return maplist;
	}

}
